using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Collections;
using System.Data;

namespace redesII
{
    public class DataBase
    {

        private string connectionString = "<connection_string>";
        private SqlCommand command;
        private SqlConnection connection;

        protected void Salvar(string query, ArrayList args)
        {
            command = new SqlCommand();
            command.CommandText = query;

            if (args != null && args.Count > 0)
            {
                SqlParameter parameter = null;
                for (int cont = 0; cont < args.Count; cont++)
                {
                    parameter.Value = args[cont];
                    parameter.SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(parameter);
                }
            }
            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();
                command.Connection = connection;
                command.ExecuteNonQuery();
            }
        }

        protected void Salvar(string query, List<WMIField> args)
        {
            //
        }

        protected SqlDataReader Carregar(string query)
        {

            SqlDataReader reader = null;

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();
                command.Connection = connection;
                reader = command.ExecuteReader();
            }

            if (reader != null) return reader;
            else return null;

        }

    }
}
